﻿/*=================================================================
* 版权信息：Copyright (C) 2005-2011 捷点科技 All Rights Reserved.
* 文件名称：CNVP_Column.cs
* 创建标识：曾乃强 15158756652 2011-03-17 11:03:01
* 修改标识：
* 功能描述：
===================================================================*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Web;
using CNVP.Config;
using CNVP.Framework.Helper;
using CNVP.Framework;

namespace CNVP.JShop.DAL
{
    /// <summary>
    /// 对*CNVP_Column*操作数据库(针对SQL Server)的实现
    /// </summary>
    public class CNVP_Column
    {
        public string StrSql=String.Empty;
       private string Prefix = DBConfig.Prefix;
        #region DAL
        public int Insert(Model.CNVP_Column obj)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("insert into  " + Prefix + "Column ([ColumnName],[ColumnType],[IsShow],[OrderID],[ColumnUrl],[TemplateUrl],[AddressRoute],[Depth],[ChildColumnNum],[IsSystemColumn],[ProductTypeID],[AllowReview],[Text])");
            sql.Append("values(@ColumnName,@ColumnType,@IsShow,@OrderID,@ColumnUrl,@TemplateUrl,@AddressRoute,@Depth,@ChildColumnNum,@IsSystemColumn,@ProductTypeID,@AllowReview,@Text)");
            sql.Append(";SELECT @@IDENTITY");

            SqlParameter[] pra = {
                            new SqlParameter("@ColumnName",obj.ColumnName),
							new SqlParameter("@ColumnType",obj.ColumnType),
							new SqlParameter("@IsShow",obj.IsShow),
							new SqlParameter("@OrderID",obj.OrderID==0?DbHelper.GetMaxID("ID","" + Prefix + "Column"):obj.OrderID),
							new SqlParameter("@ColumnUrl",obj.ColumnUrl),
							new SqlParameter("@TemplateUrl",obj.TemplateUrl),
							new SqlParameter("@AddressRoute",obj.AddressRoute),
							new SqlParameter("@Depth",obj.Depth),
							new SqlParameter("@ChildColumnNum",obj.ChildColumnNum),
							new SqlParameter("@IsSystemColumn",obj.IsSystemColumn),
                            new SqlParameter("@ProductTypeID",obj.ProductTypeID),
                            new SqlParameter("@AllowReview",obj.AllowReview),
                            new SqlParameter("@Text",obj.Text)
                                 };
            return Convert.ToInt32(DbHelper.ExecuteScalar(sql.ToString(), pra));
        }

        public int Update(Model.CNVP_Column obj)
        {
             StringBuilder sql = new StringBuilder();
             sql.Append("update " + Prefix + "Column set [ColumnName] = @ColumnName,[ColumnType] = @ColumnType,[IsShow] = @IsShow,[OrderID] = @OrderID,[ColumnUrl] = @ColumnUrl,[TemplateUrl] = @TemplateUrl,[AddressRoute] = @AddressRoute,[Depth] = @Depth,[ChildColumnNum] = @ChildColumnNum,[IsSystemColumn] = @IsSystemColumn,[ProductTypeID]=@ProductTypeID,[AllowReview]=@AllowReview,[Text]=@Text where [ID] = @ID");

            SqlParameter[] pra = { 
                            new SqlParameter("@ID",obj.ID),
							new SqlParameter("@ColumnName",obj.ColumnName),
							new SqlParameter("@ColumnType",obj.ColumnType),
							new SqlParameter("@IsShow",obj.IsShow),
							new SqlParameter("@OrderID",obj.OrderID),
							new SqlParameter("@ColumnUrl",obj.ColumnUrl),
							new SqlParameter("@TemplateUrl",obj.TemplateUrl),
							new SqlParameter("@AddressRoute",obj.AddressRoute),
							new SqlParameter("@Depth",obj.Depth),
							new SqlParameter("@ChildColumnNum",obj.ChildColumnNum),
							new SqlParameter("@IsSystemColumn",obj.IsSystemColumn),
                            new SqlParameter("@ProductTypeID",obj.ProductTypeID),
                            new SqlParameter("@AllowReview",obj.AllowReview),
                            new SqlParameter("@Text",obj.Text)
                                };
             return DbHelper.ExecuteNonQuery(sql.ToString(),pra);
        }

        public int Delete(Model.CNVP_Column obj)
        {
           StringBuilder sql = new StringBuilder();
           sql.Append("delete from " + Prefix + "Column where [ID] = @ID");
           SqlParameter[] pra = {
                                new SqlParameter("@ID",obj.ID)
						
                                };
           return DbHelper.ExecuteNonQuery(sql.ToString(),pra);
        }

        public List<Model.CNVP_Column> LoadAll(string sqlWhere)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("select [ID],[ColumnName],[ColumnType],[IsShow],[OrderID],[AllowReview],[ColumnUrl],[TemplateUrl],[AddressRoute],[Depth],[ChildColumnNum],[IsSystemColumn],[ProductTypeID],[AllowReview] from " + Prefix + "Column");
            if (sqlWhere.Trim() != "")
            {
                sql.Append(" where " + sqlWhere);
            }
            DataTable DT = DbHelper.ExecuteTable(sql.ToString());
            List<Model.CNVP_Column> list = new List<Model.CNVP_Column>();
            if (DT != null && DT.Rows.Count > 0)
            {
                foreach (DataRow dr in DT.Rows)
                {
                    Model.CNVP_Column cnvp_column = new Model.CNVP_Column();
                    cnvp_column.ID = dr["ID"] is DBNull ? 0 : (int)dr["ID"];
                    cnvp_column.ColumnName = dr["ColumnName"] is DBNull ? String.Empty : (string)dr["ColumnName"];
                    cnvp_column.ColumnType = dr["ColumnType"] is DBNull ? (byte)0 : (byte)dr["ColumnType"];
                    cnvp_column.IsShow = dr["IsShow"] is DBNull ? (byte)0 : (byte)dr["IsShow"];
                    cnvp_column.OrderID = dr["OrderID"] is DBNull ? 0 : (int)dr["OrderID"];
                    cnvp_column.ColumnUrl = dr["ColumnUrl"] is DBNull ? String.Empty : (string)dr["ColumnUrl"];
                    cnvp_column.TemplateUrl = dr["TemplateUrl"] is DBNull ? String.Empty : (string)dr["TemplateUrl"];
                    cnvp_column.AddressRoute = dr["AddressRoute"] is DBNull ? String.Empty : (string)dr["AddressRoute"];
                    cnvp_column.AllowReview = dr["AllowReview"] is DBNull ? (byte)0 : (byte)dr["AllowReview"];
                    cnvp_column.Depth = dr["Depth"] is DBNull ? String.Empty : (string)dr["Depth"];
                    cnvp_column.ChildColumnNum = dr["ChildColumnNum"] is DBNull ? 0 : (int)dr["ChildColumnNum"];
                    cnvp_column.IsSystemColumn = dr["IsSystemColumn"] is DBNull ? (byte)0 : (byte)dr["IsSystemColumn"];
                    cnvp_column.ProductTypeID = dr["ProductTypeID"] is DBNull ? 0 : (int)dr["ProductTypeID"];
                    list.Add(cnvp_column);
                }
            }
            return list;

        }
        /// <summary>
        /// 查看前几位信息
        /// </summary>
        /// <param name="topNum">前几位</param>
        /// <param name="sqlWhere"></param>
        /// <returns></returns>
        public List<Model.CNVP_Column> LoadAll(int topNum,string sqlWhere)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("select top " + topNum + " [ID],[ColumnName],[ColumnType],[IsShow],[OrderID],[AllowReview],[ColumnUrl],[TemplateUrl],[AddressRoute],[Depth],[ChildColumnNum],[IsSystemColumn],[ProductTypeID],[AllowReview] from " + Prefix + "Column");
            if (sqlWhere.Trim() != "")
            {
                sql.Append(" where " + sqlWhere);
            }
            DataTable DT = DbHelper.ExecuteTable(sql.ToString());
            List<Model.CNVP_Column> list = new List<Model.CNVP_Column>();
            if (DT != null && DT.Rows.Count > 0)
            {
                foreach (DataRow dr in DT.Rows)
                {
                    Model.CNVP_Column cnvp_column = new Model.CNVP_Column();
                    cnvp_column.ID = dr["ID"] is DBNull ? 0 : (int)dr["ID"];
                    cnvp_column.ColumnName = dr["ColumnName"] is DBNull ? String.Empty : (string)dr["ColumnName"];
                    cnvp_column.ColumnType = dr["ColumnType"] is DBNull ? (byte)0 : (byte)dr["ColumnType"];
                    cnvp_column.IsShow = dr["IsShow"] is DBNull ? (byte)0 : (byte)dr["IsShow"];
                    cnvp_column.OrderID = dr["OrderID"] is DBNull ? 0 : (int)dr["OrderID"];
                    cnvp_column.ColumnUrl = dr["ColumnUrl"] is DBNull ? String.Empty : (string)dr["ColumnUrl"];
                    cnvp_column.TemplateUrl = dr["TemplateUrl"] is DBNull ? String.Empty : (string)dr["TemplateUrl"];
                    cnvp_column.AddressRoute = dr["AddressRoute"] is DBNull ? String.Empty : (string)dr["AddressRoute"];
                    cnvp_column.AllowReview = dr["AllowReview"] is DBNull ? (byte)0 : (byte)dr["AllowReview"];
                    cnvp_column.Depth = dr["Depth"] is DBNull ? String.Empty : (string)dr["Depth"];
                    cnvp_column.ChildColumnNum = dr["ChildColumnNum"] is DBNull ? 0 : (int)dr["ChildColumnNum"];
                    cnvp_column.IsSystemColumn = dr["IsSystemColumn"] is DBNull ? (byte)0 : (byte)dr["IsSystemColumn"];
                    cnvp_column.ProductTypeID = dr["ProductTypeID"] is DBNull ? 0 : (int)dr["ProductTypeID"];
                    list.Add(cnvp_column);
                }
            }
            return list;

        }

        public Model.CNVP_Column LoadById(int ID)
        {
            
            StringBuilder sql = new StringBuilder();
            sql.Append("select [ColumnName],[ColumnType],[IsShow],[OrderID],[ColumnUrl],[TemplateUrl],[AddressRoute],[Depth],[ChildColumnNum],[IsSystemColumn],[ProductTypeID],[AlipayInInterfaceType],[PayImg], [PayAccountNumber], [PayParterID], [PayKey], [Text],[AllowReview] from " + Prefix + "Column");
            sql.Append(" where [ID] = @ID");
            SqlParameter[] pra = {
                                 new SqlParameter("@ID",ID)
						
                                    };
            DataTable DT = DbHelper.ExecuteTable(sql.ToString(),pra);
            Model.CNVP_Column cnvp_column = new Model.CNVP_Column();
            if (DT != null && DT.Rows.Count > 0)
            {
                DataRow dr = DT.Rows[0];
                cnvp_column.ColumnName = dr["ColumnName"] is DBNull ? String.Empty : (string)dr["ColumnName"];
                cnvp_column.ColumnType = dr["ColumnType"] is DBNull ? (byte)0 : (byte)dr["ColumnType"];
                cnvp_column.IsShow = dr["IsShow"] is DBNull ? (byte)0 : (byte)dr["IsShow"];
                cnvp_column.OrderID = dr["OrderID"] is DBNull ? 0 : (int)dr["OrderID"];
                cnvp_column.ColumnUrl = dr["ColumnUrl"] is DBNull ? String.Empty : (string)dr["ColumnUrl"];
                cnvp_column.TemplateUrl = dr["TemplateUrl"] is DBNull ? String.Empty : (string)dr["TemplateUrl"];
                cnvp_column.AddressRoute = dr["AddressRoute"] is DBNull ? String.Empty : (string)dr["AddressRoute"];
                cnvp_column.Depth = dr["Depth"] is DBNull ? String.Empty : (string)dr["Depth"];
                cnvp_column.ChildColumnNum = dr["ChildColumnNum"] is DBNull ? 0 : (int)dr["ChildColumnNum"];
                cnvp_column.IsSystemColumn = dr["IsSystemColumn"] is DBNull ? (byte)0 : (byte)dr["IsSystemColumn"];
                cnvp_column.AllowReview = dr["AllowReview"] is DBNull ? (byte)0 : (byte)dr["AllowReview"];
                cnvp_column.ProductTypeID = dr["ProductTypeID"] is DBNull ? 0 : (int)dr["ProductTypeID"];
                cnvp_column.AlipayInInterfaceType = dr["AlipayInInterfaceType"] is DBNull ? (byte)0 : (byte)dr["AlipayInInterfaceType"];
                cnvp_column.PayImg = dr["PayImg"] is DBNull ? String.Empty : (string)dr["PayImg"];
                cnvp_column.PayAccountNumber = dr["PayAccountNumber"] is DBNull ? String.Empty : (string)dr["PayAccountNumber"];
                cnvp_column.PayParterID = dr["PayParterID"] is DBNull ? String.Empty : (string)dr["PayParterID"];
                cnvp_column.PayKey = dr["PayKey"] is DBNull ? String.Empty : (string)dr["PayKey"];
                cnvp_column.Text = dr["Text"] is DBNull ? String.Empty : (string)dr["Text"];
            }
            return cnvp_column;
        }

        #endregion

        public DataTable GetPage(string PageName, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
        {
            try
            {
                string sql_Temp = "";
                if (SqlCondition[0].value.ToString() != "0")
                {
                    sql_Temp += " and ColumnType = " + SqlCondition[0].value.ToString() + " ";
                }
                if (SqlCondition[1].value.ToString() != "")
                {
                    sql_Temp += " and ColumnName like '%" + SqlCondition[1].value.ToString() + "%' ";
                }
                string AllFields = "ID, ColumnName, ColumnType, IsShow, OrderID, ColumnUrl,AllowReview, TemplateUrl, AddressRoute, Depth, ChildColumnNum, IsSystemColumn,ProductTypeID, PayAccountNumber, PayImg,PayParterID, PayKey, Text,AllowReview ";
                string Condition = " " + Prefix + "Column where 1=1" + sql_Temp + "";
                string IndexField = "ID";
                string OrderFields = "order by OrderID";
                return DbHelper.ExecutePage(AllFields, Condition, IndexField, OrderFields, PageIndex, PageSize, out RecordCount, out PageCount, null);
            }
            catch (Exception e)
            {
                throw new Exception("用于分页的SQL语句无效:" + e.Message);
            }

        }

       
        /// <summary>
        /// 获取栏目路径(返回值：> 新闻中心 > 行业新闻)
        /// </summary>
        /// <param name="ParentID"></param>
        /// <returns></returns>
        public string GetColumnPath(string Url, int ParentID)
        {
            string Str = "";
            string Prefix = DBConfig.Prefix;
            string StrSql = "Select ID,ColumnName,[Depth] From " + Prefix + "Column Where ID=@ParentID";
            SqlParameter[] param = { DbHelper.MakeInParam("@ParentID", SqlDbType.Int, 4, ParentID) };
            DataTable Dt = DbHelper.ExecuteTable(StrSql, param);
            if (Dt != null && Dt.Rows.Count > 0)
            {
                Str = " > <a href=\"" + Url + "?ParentID=" + Dt.Rows[0]["ID"].ToString() + "\">" + Dt.Rows[0]["ColumnName"].ToString() + "</a>" + Str;
                if (Dt.Rows[0]["Depth"].ToString() != "0")
                {
                    Str = GetColumnPath(Url, Convert.ToInt32(Dt.Rows[0]["Depth"])) + Str;
                }
            }
            return Str;
        }
        /// <summary>
        /// 读取栏目信息
        /// </summary>
        /// <param name="ColumnID"></param>
        /// <returns></returns>
        public DataTable GetColumnInfo(int ColumnID)
        {
            string Prefix = DBConfig.Prefix;
            string StrSql = "Select * From " + Prefix + "Column Where ID=@ColumnID";
            SqlParameter[] param = { DbHelper.MakeInParam("@ColumnID", SqlDbType.Int, 4, ColumnID) };
            return DbHelper.ExecuteTable(StrSql, param);
        }
        public DataTable GetTopColumnInfo(int moduleType)
        {
            string StrSql = "Select top 1  a.ColumnType,a.ColumnName,a.Text,b.OriginTitle,b.Originkey,b.OriginDescription  From " + Prefix + "Column as a left join " + Prefix + "SEOInfo as b on a.SeoInfoID= b.ID where a.ColumnType=@ColumnType  order by a.ID desc";
            SqlParameter[] param = { DbHelper.MakeInParam("@ColumnType", SqlDbType.Int, 4, moduleType) };
            return DbHelper.ExecuteTable(StrSql, param);
        }
        /// <summary>
        /// 读取类型下最新一条栏目ID
        /// </summary>
        /// <param name="moduleType">栏目类型</param>
        /// <returns>栏目ID</returns>
        public String GetTopColumnID(int moduleType)
        {
            string StrSql = "Select top 1  a.ID  From " + Prefix + "Column as a left join " + Prefix + "SEOInfo as b on a.SeoInfoID= b.ID where a.ColumnType=@ColumnType  order by a.ID desc";
            SqlParameter[] param = { DbHelper.MakeInParam("@ColumnType", SqlDbType.Int, 4, moduleType) };
            DataTable dt= DbHelper.ExecuteTable(StrSql, param);
            if (dt != null && dt.Rows.Count > 0)
            {
                return Convert.ToString(dt.Rows[0]["ID"]);
            }
            else
            {
                return "0";
            }
        }
        public DataTable GetColumnInfoForTemplate(int ColumnID)
        {
            string StrSql = "Select top 1  a.ColumnType,a.ColumnName,a.Text,b.OriginTitle,b.Originkey,b.OriginDescription  From " + Prefix + "Column as a left join " + Prefix + "SEOInfo as b on a.SeoInfoID= b.ID Where a.ID=@ColumnID";
            SqlParameter[] param = { DbHelper.MakeInParam("@ColumnID", SqlDbType.Int, 4, ColumnID) };
            return DbHelper.ExecuteTable(StrSql, param);
        }
        public int GetColoumnTemplateType(int columnID)
        {
            string StrSql = "Select top 1 [TemplateUrl]  From [" + Prefix + "Column] Where [ID]=@ColumnID";
            SqlParameter[] param = { DbHelper.MakeInParam("@ColumnID", SqlDbType.Int, 4, columnID) };
            DataTable dt = DbHelper.ExecuteTable(StrSql, param);
            if (dt != null && dt.Rows.Count > 0 && !(dt.Rows[0]["TemplateUrl"] is DBNull))
            { 
                return Convert.ToInt32(dt.Rows[0]["TemplateUrl"]);
            }
            else
            {
                return 0;
            }
        }
        /// <summary>
        /// 获取子类信息
        /// </summary>
        /// <param name="ParentID"></param>
        /// <returns></returns>
        public DataTable GetChildColumnDt(int ParentID)
        {
            string Prefix = DBConfig.Prefix;
            string StrSql = "Select * From " + Prefix + "Column Where Depth=@ParentID";
            SqlParameter[] param = { DbHelper.MakeInParam("@ParentID", SqlDbType.Int, 4, ParentID) };
            return DbHelper.ExecuteTable(StrSql, param);
        }
        public DataTable GetAllChildColumnDt(int ParentID)
        {
            string Prefix = DBConfig.Prefix;
            string StrSql = "Select * From " + Prefix + "Column Where AddressRoute like ','+@ParentID+','";
            SqlParameter[] param = { DbHelper.MakeInParam("@ParentID", SqlDbType.Int, 4, ParentID) };
            return DbHelper.ExecuteTable(StrSql, param);
        }
        public DataTable GetChildColumnDt(int ParentID, int columnType)
        {
            string Prefix = DBConfig.Prefix;
            string StrSql = "Select * From " + Prefix + "Column Where ColumnType=@ColumnType and Depth=@ParentID";
            SqlParameter[] param = { DbHelper.MakeInParam("@ColumnType", SqlDbType.Int, 4, columnType), DbHelper.MakeInParam("@ParentID", SqlDbType.Int, 4, ParentID) };
            return DbHelper.ExecuteTable(StrSql, param);
        }
        /// <summary>
        /// 更新支付方式
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int UpdatePayWay(Model.CNVP_Column obj)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("update " + Prefix + "Column set [ColumnName] = @ColumnName,[AlipayInInterfaceType]=@AlipayInInterfaceType, [PayAccountNumber]=@PayAccountNumber, [PayParterID]=@PayParterID, [PayKey]=@PayKey, [Text]=@Text,[IsShow]=@IsShow,[OrderID]=@OrderID where [ID] = @ID");

            SqlParameter[] pra = { 
                            new SqlParameter("@ID",obj.ID),
							new SqlParameter("@ColumnName",obj.ColumnName),
                            new SqlParameter("@AlipayInInterfaceType",obj.AlipayInInterfaceType),
							new SqlParameter("@PayAccountNumber",obj.PayAccountNumber),
                            new SqlParameter("@PayParterID",obj.PayParterID),
                            new SqlParameter("@PayKey",obj.PayKey),
                            new SqlParameter("@Text",obj.Text),
							new SqlParameter("@IsShow",obj.IsShow),
							new SqlParameter("@OrderID",obj.OrderID)
                                };
            return DbHelper.ExecuteNonQuery(sql.ToString(), pra);
        }

        #region "整合后的新的栏目操作方法"
                /// <summary>
        /// 栏目操作
        /// </summary>
        /// <param name="showAll">是否显示全部</param>
        /// <param name="parentID">父栏目ID</param>
        /// <returns>DataTable</returns>
        public DataTable ColumnOperate(bool showAll, int parentID)
        {
            if (showAll)
            {
                //返回全部栏目列表
                return GetColumnList(parentID);
            }
            else
            {
                //返回授权范围内的栏目列表
                return GetColumnList1(parentID);
            }
        }
        public DataTable ColumnOperate(int typeID, bool showAll, int parentID)
        {
            if (showAll)
            {
                //返回全部栏目列表
                return GetColumnList(typeID,parentID);
            }
            else
            {
                //返回授权范围内的栏目列表
                return GetColumnList1(typeID,parentID);
            }
        }
        /// <summary>
        /// 获取栏目导航(返回全部)
        /// </summary>
        /// <param name="parentID">父栏目ID</param>
        /// <returns></returns>
        public DataTable GetColumnList(Int32 parentID)
        {
            StrSql = "Select * From " + Prefix + "Column Where Depth=@ParentID Order By OrderID,ID Asc";
            SqlParameter[] param = { DbHelper.MakeInParam("@ParentID", SqlDbType.Int, 4, parentID) };
            return  DbHelper.ExecuteTable(StrSql, param);
        }
        /// <summary>
        /// 获取栏目导航(返回部分)
        /// </summary>
        /// <returns></returns>
        public DataTable GetColumnList1(Int32 parentID)
        {
            return GetColumnList(parentID);
        }

        /// <summary>
        /// 获取栏目导航(返回全部)
        /// </summary>
        /// <param name="typeID">栏目类型ID</param>
        /// <param name="parentID">父栏目ID</param>
        /// <returns></returns>
        public DataTable GetColumnList(Int32 typeID, Int32 parentID)
        {
            StrSql = "Select * From " + Prefix + "Column Where ColumnType=@TypeID and  Depth=@ParentID Order By OrderID,ID Asc";
            SqlParameter[] param = {
                                       DbHelper.MakeInParam("@TypeID", SqlDbType.Int, 4, typeID), 
                                       DbHelper.MakeInParam("@ParentID", SqlDbType.Int, 4, parentID) 
                                   };
            return  DbHelper.ExecuteTable(StrSql, param);
        }
        public DataTable GetColumnList1(Int32 typeID, Int32 parentID)
        {
            return GetColumnList(typeID, parentID);
        }

        /// <summary>
        /// 判断是否存在子类
        /// </summary>
        /// <param name="ParentID">父级栏目ID</param>
        /// <returns>bool</returns>
        public bool IsChildMenu(int ParentID)
        {
            bool flg = false;
            StrSql = "Select ID From " + Prefix + "Column Where Depth=@ParentID Order By OrderID,ID Asc";
            SqlParameter[] param = { DbHelper.MakeInParam("@ParentID", SqlDbType.Int, 4, ParentID) };
            DataTable Dt = DbHelper.ExecuteTable(StrSql, param);
            if (Dt != null && Dt.Rows.Count > 0)
            {
                flg = true;
            }
            return flg;
        }
        public bool IsChildMenu(int parentID,int typeID)
        {
            bool flg = false;
            StrSql = "Select ID From " + Prefix + "Column Where ColumnType=@TypeID and  Depth=@ParentID Order By OrderID,ID Asc";
            SqlParameter[] param = { 
                                       DbHelper.MakeInParam("@TypeID", SqlDbType.Int, 4, typeID),
                                       DbHelper.MakeInParam("@ParentID", SqlDbType.Int, 4, parentID)
                                   };
            DataTable Dt = DbHelper.ExecuteTable(StrSql, param);
            if (Dt != null && Dt.Rows.Count > 0)
            {
                flg = true;
            }
            return flg;
        }
        #endregion
    }
}
